﻿#ifndef CFILESTORAGECLIENTIMPL_H
#define CFILESTORAGECLIENTIMPL_H

#define NOMINMAX // 关键：禁用 Windows 的 min/max 宏

#include <cstdint>
#include <string>
#include <vector>
#include "StringTool.h"

class CFilestorageClientImpl
{
public:
    CFilestorageClientImpl();
    ~CFilestorageClientImpl() = default;

    void setServiceAddress(const std::string &url);
    std::wstring getLastErrorText() const;

    bool pushFile(const std::wstring &localPath, const std::wstring &remotePath);
    bool pullFile(const std::wstring &localPath, const std::wstring &remotePath);
    bool pushData(const std::vector<uint8_t> &localData, const std::string &remotePath);
    bool pullData(std::vector<uint8_t> &localData, const std::string &remotePath);

private:
    std::string serviceAddress;
    std::wstring lastErrorText;
    static const size_t CHUNK_SIZE = 10 * 1024 * 1024; // 10MB

    // 辅助函数
    bool sendChunk(const std::string &remotePath, uint64_t offset, const std::vector<uint8_t> &chunk);
    bool receiveChunk(const std::string &remotePath, uint64_t offset, std::vector<uint8_t> &chunk);
    static std::string base64Encode(const std::vector<uint8_t> &data);
    static std::vector<uint8_t> base64Decode(const std::string &encoded);
};

#endif // CFILESTORAGECLIENTIMPL_H
